
package il.ac.biu.cs.grossmm.api.simple;

/**
 * Represents a subscription event, as defined in RFC 3857. Subscription events
 * may cause FSM state transictions as defined in RFC 3857:
 * 
 * <pre>
 *   
 *            subscribe,
 *         policy=       +----------+
 *         reject        |          |&lt;------------------------+
 *         +------------&gt;|terminated|&lt;---------+              |
 *         |             |          |          |              |
 *         |             |          |          |noresource    |
 *         |             +----------+          |rejected      |
 *         |                  &circ;noresource      |deactivated   |
 *         |                  |rejected        |probation     |
 *         |                  |deactivated     |timeout       |noresource
 *         |                  |probation       |              |rejected
 *         |                  |giveup          |              |giveup
 *         |                  |                |              |approved
 *      +-------+         +-------+        +-------+          |
 *      |       |subscribe|       |approved|       |          |
 *      | init  |--------&gt;|pending|-------&gt;|active |          |
 *      |       |no policy|       |        |       |          |
 *      |       |         |       |        |       |          |
 *      +-------+         +-------+        +-------+          |
 *         |                  |                &circ;              |
 *         | subscribe,       |                |              |
 *         +-----------------------------------+              |
 *           policy = accept  |            +-------+          |
 *                            |            |       |          |
 *                            |            |waiting|----------+
 *                            +-----------&gt;|       |
 *                             timeout     |       |
 *                                         +-------+
 *   
 * </pre>
 * 
 */
public enum SubscriptionEvent {

	/**
	 * Approved by the owner of the resource, or according to the policy
	 */
	APPROVED,

	/**
	 * The subscription has been terminated, but the subscriber SHOULD retry
	 * immediately with a new subscription. One primary use of such a status
	 * code is to allow migration of subscriptions between nodes. The
	 * "retry-after" parameter has no semantics for "deactivated".
	 */
	DEACTIVATED,

	/**
	 * The subscription has been terminated because the notifier could not
	 * obtain authorization in a timely fashion. If a "retry- after" parameter
	 * is also present, the client SHOULD wait at least the number of seconds
	 * specified by that parameter before attempting to re-subscribe; otherwise,
	 * the client MAY retry immediately, but will likely get put back into
	 * pending state.
	 */
	GIVEUP,

	/**
	 * The subscription has been terminated because the resource state which was
	 * being monitored no longer exists. Clients SHOULD NOT attempt to
	 * re-subscribe. The "retry-after" parameter has no semantics for
	 * "noresource".
	 */
	NORESOURCE,

	/**
	 * The subscription has been terminated, but the client SHOULD retry at some
	 * later time. If a "retry-after" parameter is also present, the client
	 * SHOULD wait at least the number of seconds specified by that parameter
	 * before attempting to re- subscribe.
	 */
	PROBATION,

	/**
	 * The subscription has been terminated due to change in authorization
	 * policy. Clients SHOULD NOT attempt to re-subscribe. The "retry-after"
	 * parameter has no semantics for "rejected".
	 */
	REJECTED,

	/**
	 * The watcher attempted to register a new subscription
	 */
	SUBSCRIBE,

	/**
	 * The subscription has been terminated because it was not refreshed before
	 * it expired. Clients MAY re-subscribe immediately. The "retry-after"
	 * parameter has no semantics for "timeout".
	 */
	TIMEOUT;
}
